﻿using BaseSimpleAPI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using UDPHelper;

namespace AMInstantMessaging
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            UDPClientHelper.GetInstance().Start();
            BaseControllerCallHelper.GetInstance().NetCallFunc = (url, obj) =>
            {
                UDPPackage package = new UDPPackage
                {
                    Body = obj,
                };

                UDPPackageHelper.SetUrl(package, url);

                var reponse = UDPClientHelper.GetInstance().SendPackageToServerAndWaitResponse(package);
                return reponse == null || reponse.Body == null ? string.Empty : reponse.Body.ToString();
            };

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FormMain());

            UDPClientHelper.GetInstance().Stop();
        }
    }
}
